using System.Collections.Generic;
using Nop.Core.Domain.Customers;
using Nop.Core.Domain.Security;

namespace Nop.Services.Security
{
    /// <summary>
    /// Permission service interface
    /// </summary>
    public partial interface IPermissionService
    {
        /// <summary>
        /// Delete a permission
        /// </summary>
        /// <param name="permission">Permission</param>
        void DeletePermissionRecord(PermissionRecord permission);

        /// <summary>
        /// Gets a permission
        /// </summary>
        /// <param name="permissionId">Permission identifier</param>
        /// <returns>Permission</returns>
        PermissionRecord GetPermissionRecordById(int permissionId);

        /// <summary>
        /// Gets a permission
        /// </summary>
        /// <param name="systemName">Permission system name</param>
        /// <returns>Permission</returns>
        PermissionRecord GetPermissionRecordBySystemName(string systemName);

        /// <summary>
        /// Gets all permissions
        /// </summary>
        /// <returns>Permissions</returns>
        IList<PermissionRecord> GetAllPermissionRecords();

        /// <summary>
        /// Inserts a permission
        /// </summary>
        /// <param name="permission">Permission</param>
        void InsertPermissionRecord(PermissionRecord permission);

        /// <summary>
        /// Updates the permission
        /// </summary>
        /// <param name="permission">Permission</param>
        void UpdatePermissionRecord(PermissionRecord permission);

        /// <summary>
        /// Install permissions
        /// </summary>
        /// <param name="permissionProvider">Permission provider</param>
        void InstallPermissions(IPermissionProvider permissionProvider);

        /// <summary>
        /// Uninstall permissions
        /// </summary>
        /// <param name="permissionProvider">Permission provider</param>
        void UninstallPermissions(IPermissionProvider permissionProvider);

        /// <summary>
        /// Authorize permission
        /// </summary>
        /// <param name="permission">Permission record</param>
        /// <returns>true - authorized; otherwise, false</returns>
        bool Authorize(PermissionRecord permission);

        
        /// <summary>
        /// Gets the store ID can be managed by current customer.
        /// </summary>
        /// <param name="permission">The permission can manage all stores</param>
        /// <param name="verifyManageStoreRole">Whether verify the manage store role of the current customer</param>
        /// <returns>store ID; 1 indicates can manage all stores, 0 indicates no permission</returns>
        int GetAuthorizedStore(PermissionRecord permission = null, bool verifyManageStoreRole = true);

        /// <summary>
        /// Authorize permission
        /// </summary>
        /// <param name="permission">Permission record</param>
        /// <param name="customer">Customer</param>
        /// <returns>true - authorized; otherwise, false</returns>
        bool Authorize(PermissionRecord permission, Customer customer);

        /// <summary>
        /// Authorize permission
        /// </summary>
        /// <param name="permissionRecordSystemName">Permission record system name</param>
        /// <returns>true - authorized; otherwise, false</returns>
        bool Authorize(string permissionRecordSystemName);

        /// <summary>
        /// Authorize permission
        /// </summary>
        /// <param name="permissionRecordSystemName">Permission record system name</param>
        /// <param name="customer">Customer</param>
        /// <returns>true - authorized; otherwise, false</returns>
        bool Authorize(string permissionRecordSystemName, Customer customer);

        /// <summary>
        /// Security access for store manager, store admin and admin
        /// </summary>
        /// <param name="curManagedStoreId">Store manage identifier</param>
        /// <param name="isStoreAdmin">Store admin</param>
        /// <param name="canManageAllStore">Admin</param>
        /// <param name="isAccessDenied">Access denied</param>
        void SecurityAccessForAll(out int curManagedStoreId, out bool isStoreAdmin, out bool canManageAllStore, out bool isAccessDenied);

        /// <summary>
        /// Security access for store manager and admin
        /// </summary>
        /// <param name="curManagedStoreId">Store manage identifier</param>
        /// <param name="canManageAllStore">Admin</param>
        /// <param name="isAccessDenied">Access denied</param>
        void SecurityAccessForStoreManager(out int curManagedStoreId, out bool canManageAllStore, out bool isAccessDenied);

        /// <summary>
        /// Security access for store admin and admin
        /// </summary>
        /// <param name="isStoreAdmin">Store admin</param>
        /// <param name="canManageAllStore">Admin</param>
        /// <param name="isAccessDenied">Access denied</param>
        void SecurityAccessForStoreAdmin(out bool isStoreAdmin, out bool canManageAllStore, out bool isAccessDenied);
    }
}